using UnityEngine;

public class SwipeCamera : MonoBehaviour
{
	public GameObject centerCameraEnabledButton;

	public GameObject centerCameraDisabledButton;

	public GameObject rightCameraEnabledButton;

	public GameObject rightCameraDisabledButton;

	public GameObject FPSCameraEnabledButton;

	public GameObject FPSCameraDisabledButton;

	private void OnEnable()
	{
		settings.MainCameraType mainCameraType = (settings.MainCameraType)Load.LoadInt(settings.keyCamActive);
		if (!settings.offlineMode && !settings.offlineMode && GameController.instance != null && GameController.instance.curTypeGame == TypeGame.Zombe && mainCameraType == settings.MainCameraType.FPSCamera && PlayerBehavior.MyPlayer.localTeam == PunTeams.Team.red)
		{
			mainCameraType = settings.MainCameraType.TPSCamera;
		}
		switch (mainCameraType)
		{
		case settings.MainCameraType.TPSCamera:
			EnableTPSCamera();
			break;
		case settings.MainCameraType.RPGCamera:
			EnableRPGCamera();
			break;
		case settings.MainCameraType.FPSCamera:
			EnableFPSCamera();
			break;
		}
	}

	public void EnableRPGCamera()
	{
		Save.SaveInt(settings.keyCamActive, 1);
		PlayerPrefs.Save();
		centerCameraEnabledButton.SetActive(false);
		centerCameraDisabledButton.SetActive(false);
		FPSCameraEnabledButton.SetActive(true);
		FPSCameraDisabledButton.SetActive(false);
		rightCameraEnabledButton.SetActive(false);
		rightCameraDisabledButton.SetActive(true);
		if (CameraModeControl.instance != null)
		{
			CameraModeControl.instance.EnableRPGCamera(false, true);
		}
	}

	public void EnableTPSCamera()
	{
		Save.SaveInt(settings.keyCamActive, 0);
		PlayerPrefs.Save();
		centerCameraEnabledButton.SetActive(false);
		centerCameraDisabledButton.SetActive(false);
		FPSCameraEnabledButton.SetActive(true);
		FPSCameraDisabledButton.SetActive(false);
		rightCameraEnabledButton.SetActive(false);
		rightCameraDisabledButton.SetActive(true);
		if (CameraModeControl.instance != null)
		{
			CameraModeControl.instance.EnableTpsCamera(false, true);
		}
	}

	public void EnableFPSCamera()
	{
		Save.SaveInt(settings.keyCamActive, 2);
		PlayerPrefs.Save();
		FPSCameraEnabledButton.SetActive(false);
		FPSCameraDisabledButton.SetActive(true);
		centerCameraEnabledButton.SetActive(false);
		centerCameraDisabledButton.SetActive(false);
		rightCameraEnabledButton.SetActive(true);
		rightCameraDisabledButton.SetActive(false);
		if (!settings.offlineMode && GameController.instance != null && GameController.instance.curTypeGame == TypeGame.Zombe && TDMController.myTeam == PunTeams.Team.red)
		{
			if (CameraModeControl.instance != null)
			{
				CameraModeControl.instance.EnableTpsCamera(false, true);
			}
		}
		else if (CameraModeControl.instance != null)
		{
			CameraModeControl.instance.EnableFPSCamera();
		}
	}
}
